import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

class CustomWeatherComponent extends StatefulWidget {
  const CustomWeatherComponent({super.key});

  @override
  State<CustomWeatherComponent> createState() => _CustomWeatherComponentState();
}

class _CustomWeatherComponentState extends State<CustomWeatherComponent> {



  @override
  Widget build(BuildContext context) {
    return const Placeholder();
  }

  @override
  void initState() {
    super.initState();
    checkLocationPermission();
  }

  Future<void> checkLocationPermission() async {
    final status = await Permission.locationWhenInUse.status;
    if (status.isGranted) {
      // 已授权
    } else {
      if (await Permission.locationWhenInUse.serviceStatus.isEnabled) {
        // Use location.开启定位使用权限

      }
    }
    if (status.isDenied) {
      await Permission.locationWhenInUse.request();
    } else if (status.isRestricted) {

    } else if (status.isGranted) {

    }
  }
}
